package com.yxhl.zoume.utils;

import android.content.Context;

import com.github.pwittchen.prefser.library.Prefser;
import com.yxhl.zoume.data.http.model.account.ZMAccount;

/**
 * 当前用户账号管理
 * Created by Xboy on 16/4/17.
 */


public class AccountUtils {

    private static final String KEY_ACCOUNT = "CURRENT_ACCOUNT";
    private static AccountUtils instance = null;
    private Prefser prefser;

    public AccountUtils(Context context) {
        if (null == prefser) {
            prefser = new Prefser(context);
        }
    }

    public static AccountUtils getInstance(Context context) {
        if (instance == null) {
            synchronized (AccountUtils.class) {
                if (instance == null) {
                    instance = new AccountUtils(context);
                }
            }
        }
        return instance;
    }

    public void saveAccount(ZMAccount account) {
        prefser.put(KEY_ACCOUNT, account);
    }

    //    ZMAccount zmAccount = new ZMAccount();
    public ZMAccount getAccount() {

//        String mobile = "13500000000"; //for test
//        String token = "CB0C485BE6565DDB3FF5FF6E0B75C58A"; //for test
//        zmAccount.setAccountName(mobile);
//        zmAccount.setAccessToken(token);

        return prefser.get(KEY_ACCOUNT, ZMAccount.class, null);
    }


}
